<?php

/**
 * This file is part of the Pagizer package.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @copyright   Copyright (c) 2010 Advisa (http://www.advisa.fr)
 * @author      Pagizer Core Team <team@pagizer.org>
 * @package     pagizer
 * @subpackage  backoffice
 */

/**
 * Display a publication switch
 *
 * @param document $document
 * 
 * @example {publicationStatusSwitch document=$document}
 */
function smarty_function_publicationStatusSwitch($params, &$smarty)
{
    if(isset($params['document']))
    {
        $document = $params['document'];
    }
    else
    {
        $document = f_document_Provider::getInstance()->getByUniqueId($params['docId'], $params['docLang']);
    }

    /* @var $document f_document_BaseDocument */

    if(is_object($document) && $document instanceof f_document_baseDocument)
    {

        $js = 'onclick="publicationStatusSwitch('.$document->getUniqueId().', \''.$document->getLang().'\', \''.$document->getModel().'\'); return false;"';
        $style = "itemStatusButton".$document->getPublicationstatus();
        echo '<a href="javascript:void(0);" '. $js  .' class="'.$style.' publicationSwitchButton" id="docStatusPic_'.$document->getUniqueId().'"></a>';
    }
}